﻿@inject IStringLocalizer<Foo> Localizer
@inject IStringLocalizer<TableBaseNormal> TablesLocalizer

<Button Icon="fa-solid fa-arrows-rotate" Text="@RefreshText" OnClick="OnClick" class="my-2" />

<Table TItem="Foo" Items="@Items.Take(3)">
    <TableColumns>
        <TableColumn @bind-Field="@context.DateTime" Width="180" />
        <TableColumn @bind-Field="@context.Name" />
        <TableColumn @bind-Field="@context.Address" />
    </TableColumns>
</Table>

@code {
    /// <summary>
    /// Foo 类为Demo测试用，如有需要请自行下载源码查阅
    /// Foo class is used for Demo test, please download the source code if necessary
    /// https://gitee.com/LongbowEnterprise/BootstrapBlazor/blob/main/src/BootstrapBlazor.Shared/Data/Foo.cs
    /// </summary>
    [NotNull]
    private List<Foo>? Items { get; set; }

    [NotNull]
    private string? RefreshText { get; set; }

    /// <summary>
    /// OnInitialized
    /// </summary>
    protected override void OnInitialized()
    {
        base.OnInitialized();
        //获取随机数据
        //Get random data
        Items = Foo.GenerateFoo(Localizer);

        RefreshText ??= TablesLocalizer["TableBaseNormalRefreshText"];
    }

    private void OnClick()
    {
        Items = Foo.GenerateFoo(Localizer);
    }
}
